//
//  ReduceCode.m
//  YSFruit
//
//  Created by iMacOne on 16/4/7.
//  Copyright © 2016年 iMacOne. All rights reserved.
//

#import "ReduceCode.h"
#import "Header.h"
@implementation ReduceCode
+ (UIButton *)creatBtnWithFrame:(CGRect)rect btnTitle:(NSString *)titleString btnTitleColor:(UIColor *)color btnTitleFont:(int)font btnBackgroundColor:(UIColor *)BGcolor backgroundImage:(UIImage *)image  isCorner:(BOOL)corner
{
    UIButton * btn =[UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = rect;
    [btn setTitle:titleString forState:UIControlStateNormal];
    [btn setTitleColor:color forState:UIControlStateNormal];
    btn.titleLabel.font = FONT(font);
    btn.backgroundColor = BGcolor;
    [btn setBackgroundImage:image forState:UIControlStateNormal];
    if (corner) {
        btn.layer.cornerRadius = btn.frame.size.width/2;
        btn.layer.masksToBounds = YES;
    }
    return btn;
}
+ (UILabel *)creatLabelWithFrame:(CGRect)rect title:(NSString*)title titleColor:(UIColor *)color font:(int)font textAlignment:(int)alignment
{
    UILabel * lbl = [[UILabel alloc]initWithFrame:rect];
    lbl.text = title;
    lbl.font = FONT(font);
    lbl.textColor = color;
    lbl.textAlignment = alignment;
    return lbl;
}
+ (UIImageView *)creatImageVeiwWithFrame:(CGRect)rect imageName:(NSString *)imageName isCorner:(BOOL)isCorner
{
    UIImageView * imageV = [[UIImageView alloc] initWithFrame:rect];
    imageV.image = [UIImage imageNamed:imageName];
    if (isCorner) {
        imageV.layer.masksToBounds = YES;
        imageV.layer.cornerRadius = imageV.frame.size.width/2;
    }
    return imageV;
}
+ (UIButton *)creatBtnWithFrame:(CGRect)rect imageName:(NSString *)imageName labelTitle:(NSString *)labelTitle isBorder:(BOOL)isBorder{
    UIButton * commentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    commentBtn.frame = rect;
//    commentBtn.backgroundColor = [UIColor purpleColor];
    if (isBorder) {
        commentBtn.layer.borderWidth=0.5;
        commentBtn.layer.borderColor = [UIColor whiteColor].CGColor;
        commentBtn.layer.cornerRadius = 5;
    }
    UIImageView * img = [[UIImageView alloc] initWithFrame:CGRectMake(5, 2.5, 20, 20)];
    img.image = [UIImage imageNamed:imageName];
    [commentBtn addSubview:img];
    UILabel * lbl = [ReduceCode creatLabelWithFrame:CGRectMake(30, 0, rect.size.width-30, 25) title:labelTitle titleColor:[UIColor whiteColor] font:12 textAlignment:0];
    [commentBtn addSubview:lbl];
    return commentBtn;
}
@end
